/**
 * Copyright (C) 2009 Ignasi Fosch Alonso
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * You can reach me by mail at natx@y10k.ws
 * You can reach him by paper mail at:
 * C. LLEIDA, 41-43, 3r 1a
 * El Prat de Llobregat 08820
 * Barcelona, SPAIN
 */
package ws.y10k.goloim.model;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author natx
 *
 */
public class TestProducts {
	
	private static Products products;

	/**
	 *
	 */
	@BeforeClass
	public static void setUpBeforeClass() {
		products = new Products();
	}
	
	/**
	 * Test method for {@link ws.y10k.goloim.model.Boxes#add(ws.y10k.goloim.model.Box)}.
	 */
	@Test(expected=ProductAlreadyExistsException.class)
	public final void testBasicOps() throws ProductAlreadyExistsException {
		assertFalse(products.productExists("4444"));
		try {
			products.add(new Product("4444", "test product", "test product details", "Reny Picot", 0, 0, 0, new Box(10,10,10,10), 0, 0, new Pallet("EUR80","Eur 80",10,10,10,10), false));
		} catch (ProductAlreadyExistsException e) {
			fail("Failed adding a new product. Model response: This product already exists.");
		}
		assertTrue(products.productExists("4444"));
		try {
			@SuppressWarnings("unused")
			Product firstProduct = products.getProduct("4444");
		} catch (ProductDoesNotExistException e) {
			fail("Failed getting an existing product. Model response: This product doesn't exist.");
		}
		assertFalse(products.productExists("5555"));
		try {
			products.add(new Product("6666", "test product", "test product details", "Reny Picot", 0, 0, 0, new Box(10,10,10,10), 0, 0, new Pallet("EUR80","Eur 80",10,10,10,10), false));
		} catch (ProductAlreadyExistsException e) {
			fail("Failed adding a new product. Model response: This product already exists.");
		}
		assertTrue(products.productExists("6666"));
		products.add(new Product("4444", "test product", "test product details", "Reny Picot", 0, 0, 0, new Box(10,10,10,10), 0, 0, new Pallet("EUR80","Eur 80",10,10,10,10), false));	 
	}

}
